package cn.iocoder.yudao.module.mzt.dal.mysql.article;

import java.util.*;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.mzt.dal.dataobject.article.ArticleDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.mzt.controller.admin.article.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 文章 Mapper
 *
 * @author Geordie
 */
@Mapper
public interface ArticleMapper extends BaseMapperX<ArticleDO> {


    List<ArticleDO> selectPageWithRelations(@Param("reqVO") ArticlePageReqVO reqVO);

    List<ArticleDO> inquireArticle(@Param("categoryId") Long categoryId, @Param("tagId") Long tagId, @Param("keywords") String keywords);

    ArticleDO selectWithRelations(@Param("id") Long id);

    @Select("SELECT id,title FROM mzt_article WHERE id < #{id} and category_id = #{categoryId} ORDER BY id DESC LIMIT 1")
    ArticleDO selectPreviousArticle(@Param("id") Long id, @Param("categoryId") Long categoryId);

    @Select("SELECT id,title FROM mzt_article WHERE id > #{id} and category_id = #{categoryId} ORDER BY id ASC LIMIT 1")
    ArticleDO selectNextArticle(@Param("id") Long id, @Param("categoryId") Long categoryId);
}
